package lc20240625;

public class JudgePalin {
    public static boolean isPalindrome(int x) {
        String s = String.valueOf(x);
        int len = s.length() - 1;
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i)!=s.charAt(len-i)){
                return false;
            }
        }
        return true;
    }
    public static boolean isPalindrome2(int x) {
        if (x<0||(x%10==0&&x!=0)){
            return false;
        }
        int remainder=0;
        while (x>remainder){
            remainder=remainder*10+x%10;
            x=x/10;
        }
        if (x==remainder||x==remainder/10){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(isPalindrome2(1212));
    }
}
